
const {ccclass, property} = cc._decorator;

@ccclass
export default class Follow extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    @property(cc.Node)
    target:cc.Node = null;

    onLoad () {
        // console.log(this.target.getPosition());
        // this.node.x = this.target.getPosition().x;
    }

    start () {

    }

    update (dt) {
        // 判断摄像头位置
        if (this.target.getPosition().x <= -280 ) {
            this.node.x = -280;
        } else if (this.target.getPosition().x >= 1625) {
            this.node.x = 1625;
            
        } else {
            this.node.x = this.target.getPosition().x;
        }
        
    }
}
